package com.dgut.usermanager.service;

import com.dgut.usermanager.dao.UserAccountDao;
import com.dgut.usermanager.entity.UserAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class UserAccountServiceImp implements UserAccountService{
    @Autowired
    UserAccountDao userAccountDao;
    public UserAccountServiceImp() {
        super();
    }

    @Override
    public Optional<UserAccount> findUserAccountById(Integer id) {
        return userAccountDao.findById(id);
    }

    @Override
    public List<UserAccount> findAllUserAccount() {
        return userAccountDao.findAll();
    }

    @Override
    public UserAccount findUserAccountByAccount(String account) {
        return userAccountDao.findUserAccountByAccount(account);
    }

    @Override
    public void deleteUserAccountById(Integer id) {
        userAccountDao.deleteById(id);
    }

    @Override
    public UserAccount updateUserAccount(UserAccount userAccount) {
        return userAccountDao.save(userAccount);
    }

    @Override
    public UserAccount AddUserAccount(UserAccount userAccount) {
        return userAccountDao.save(userAccount);
    }
}
